/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package photoshare.services;

import java.sql.SQLException;
import java.util.ArrayList;
import photoshare.dao.AccountDAO;
import photoshare.dto.AccountDTO;

/**
 *
 * @author PhotoShare
 */
public class AccountService {

    public AccountService() {
    }

    public boolean create(AccountDTO accDTO) throws SQLException {
        return new AccountDAO().create(accDTO);
    }

    public ArrayList<AccountDTO> findAll() {
        return new AccountDAO().readAll();
    }

    public AccountDTO findById(Integer accountId) {
        return new AccountDAO().readById(accountId);
    }

    public ArrayList<AccountDTO> findByIsActive(boolean isActive) {
        return new AccountDAO().readByIsActive(isActive);
    }

    public boolean updateById(AccountDTO accountDTO, Integer accountId) throws SQLException {
        return new AccountDAO().updateById(accountDTO, accountId);
    }

    public boolean deleteById(Integer accountId) throws SQLException {
        return new AccountDAO().deleteById(accountId);
    }

    public boolean authenticate(String username, String password){
        return new AccountDAO().login(username, password);
    }

    public boolean changePassword(Integer accountId, String currentPassword, String newPassword) throws SQLException{
        return new AccountDAO().changePassword(accountId, currentPassword, newPassword);
    }

}
